package com.ls.controller;


import com.ls.base.BaseResult;
import com.ls.controller.model.channel.AddChannelModel;
import com.ls.controller.model.channel.EditChannelModel;
import com.ls.controller.model.channel.QueryChannelModel;
import com.ls.controller.model.channel.SendSmsWithChannelModel;
import com.ls.entity.SysUser;
import com.ls.service.ICommChannelService;
import com.ls.utils.login.CurrentUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.Valid;

/**
 * <p>
 * 上游通道表，不做每分钟的字段限制，这个统一在后台代码中限制 前端控制器
 * </p>
 *
 * @author pengyu
 * @since 2019-12-05
 */
@Api(value = "上游通道相关接口", description = "上游通道相关接口")
@Controller
@RequestMapping("/commChannel")
public class CommChannelController {

    @Autowired
    ICommChannelService service;

    /**
     * 新增
     */
    @ApiOperation(value = "新增")
    @PostMapping(value = "add")
    @ResponseBody
    public BaseResult add(@Valid @RequestBody AddChannelModel model, @CurrentUser SysUser currentUser) {
        return service.add(model, currentUser);
    }

    /**
     * 修改
     */
    @ApiOperation(value = "新增")
    @PostMapping(value = "edit")
    @ResponseBody
    public BaseResult edit(@Valid @RequestBody EditChannelModel model, @CurrentUser SysUser currentUser) {
        return service.edit(model, currentUser);
    }

    /**
     * 查询
     */
    @ApiOperation(value = "查询分页列表")
    @GetMapping(value = "listByPage")
    @ResponseBody
    public BaseResult listByPage(QueryChannelModel model, @CurrentUser SysUser currentUser) {
        return service.listByPage(model, currentUser);
    }

    /**
     * TODO 测试短信通道，需要在 JiaNuoSms 提取出 静态方法后才能完成
     */
//    @ApiIgnore
    @ApiOperation(value = "测试短信通道")
    @PostMapping(value = "testSendSms")
    @ResponseBody
    public BaseResult testSendSms(@Valid @RequestBody SendSmsWithChannelModel model, @CurrentUser SysUser currentUser) {
        return service.testSendSms(model, currentUser);
    }



}

